<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/js/echarts.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function(){
        trbgmoves('#d3dff2');
        $('#interval').val(<?=$interval?>);
    });
    function ViewCountRule(){
        layer.tips('维修点负载数据统计：<br>'+
        '1、站点范围：西班牙维修点，德国维修点<br>'+
        '2、时间范围：从起始时间到现在，默认最后一个月<br>'+
        '3、数据类型：<br>'+
        '3.1、老订单，根据订单状态来取：<br>'+
        '3.1.1、已接收单量＝检测完成_待维修+检测完成_待QC<br>'+
        '3.1.2、已维修处理单量＝已报价+维修中+维修完成+装配完成_待QC（*同一订单同时出现任意二者只计1）<br>'+
        '3.2、新订单，根据产品订单状态来取<br>'+
        '3.2.1、已接收单量＝检测完成_待维修+检测完成_待QC<br>'+
        '3.2.2、已维修处理单量＝【已报价+待报价（*同一产品同时存在已报价&待报价时只计1）】+待发货+【接单质检+检测完成_待入库（*不计退货类型订单合格单的数量，且接单质检，检测完成_待入库状态同时存在同一产品时只计1）】', '#tips', {
            tips: [2, '#3595CC'],
            time: 400000,
            area: '500px'
        });
    }
    function  CloseCountRule(){
        layer.closeAll('tips');
    }
    function test(){
        layer.msg('功能开发中',{icon:5});
    }
</script>


<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript">
/**
 * 获取产品分类数据
 */
function getProductClassData(num){
    var tid='';
    var bid='';
    var item={};
    var html="<option value=''>-请选择-</option>";
    switch (num){
        case 1:
            $('#brand_id').html(html);
            $('#model_id').html(html);
            tid=$('#categoryId').val();
            item={'tid':tid};
            break;
        case 2:
            $('#model_id').html(html);
            tid=$('#categoryId').val();
            bid=$('#brand_id').val();
            item={'tid':tid,'bid':bid};
            break;
        default :
            alert('参数异常');
            return false;
    }
    var load=layer.load(2);
    $.post("<?=blang_url('ajax/ajax/getProductClassAll')?>",item,function(data){
        if(data){
            layer.close(load);
            if(data==101){
                alert('当前分类下没有任何数据');
            }else {
                var productData = JSON.parse(data);
                for (var i = 0; i < productData.length; i++) {
                    html += "<option value='" + productData[i]['sap_id'] + "'>" + productData[i]['name'] + "</option>";
                }
                switch (num) {
                    case 1:
                        $('#brand_id').html(html);
                        break;
                    case 2:
                        $('#model_id').html(html);
                        break;
                    default :
                        break;
                }
            }
        }
    });
}
</script>

<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
          <h1><?=lang('menu_maintain_report')?></h1>
          <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-bar-chart-o"></i><?=lang('menu_maintain_report')?></h3>
          </div>
          <div class="panel-body">
            <div class="well" style="padding:0 19px;">
              <div class="row">
                <form action="<?=blang_url('maintainReport/maintainReport/StatisticsOrderStatus/')?>" method="post" enctype="multipart/form-data" name="searchform" >
                    <div class="col-sm-4">
                        <div class="form-group">
                            <div class="form-group">
                                <label class="control-label"><?=lang('order_kssj')?></label>
                                <input type="text" name="startTime" value="" onfocus="WdatePicker({lang:'en'})" class="form-control Wdate" />
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <div class="form-group">
                                <label class="control-label"><?=lang('order_jssj')?></label>
                                <input type="text" name="endTime" value="" onfocus="WdatePicker({lang:'en'})" class="form-control Wdate" />
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group" style="padding-top: 50px;">
                            <input class="btn btn-primary" type="submit"  name="searchSubmit" value="<?=lang('file_cx')?>" /> 
                            <a href="javascript:void(0)" onclick="test()" class="btn btn-oms"><i class="fa fa-download"></i>&nbsp;导出Excel</a>
                        </div>
                    </div>
                </form>
                
              </div>
            </div>
            <div class="table-responsive">
                <div id="main" style='height:600px;width:100%;'></div>
                <script type="text/javascript">
                    var myChart = echarts.init(document.getElementById('main'));
                    myChart.showLoading();
                    var datas = JSON.parse('<?=$statisticsData?>');
                    myChart.hideLoading();
                    // 基于准备好的dom，初始化echarts实例
                    var option = {

                        title: {
                            text: 'OMS维修数据',
                            subtext: '数据来自丹宏昊天网络科技有限公司'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            data:['西班牙-接单量','西班牙-维修处理单量','德国-接单量','德国-维修处理单量']
                        },
                        toolbox: {
                            show: true,
                            feature: {
                                dataZoom: {},
                                dataView: {readOnly: false},
                                magicType: {type: ['line', 'bar']},
                                restore: {},
                                saveAsImage: {}
                            }
                        },
                        xAxis:  {
                            type: 'category',
                            boundaryGap: false,
                            data: datas['timeLine']//['周一','周二','周三','周四','周五','周六','周日']
                        },
                        yAxis: {
                            type: 'value',
                            axisLabel: {
                                formatter: '{value}'
                            }
                        },
                        dataZoom:{
                            type:'slider'
                        },
                        series: [
                            {
                                name:'西班牙-接单量',
                                type:'line',
                                data:datas['reception']['es'],//[11, 11, 15, 13, 12, 13, 10],
                                markPoint: {
                                    data: [
                                        {type: 'max', name: '最大值'},
                                        {type: 'min', name: '最小值'}
                                    ]
                                },
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            },
                            {
                                name:'西班牙-维修处理单量',
                                type:'line',
                                data:datas['maintain']['es'],//[1, 8, 2, 5, 3, 2, 0],
                                markPoint: {
                                    data: [
                                        {type: 'max', name: '最大值'},
                                        {type: 'min', name: '最小值'}
                                    ]
                                },
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            },
                            {
                                name:'德国-接单量',
                                type:'line',
                                data:datas['reception']['de'],//[1, 4, 2, 5, 6, 2, 0],
                                markPoint: {
                                    data: [
                                        {type: 'max', name: '最大值'},
                                        {type: 'min', name: '最小值'}
                                    ]
                                },
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            },
                            {
                                name:'德国-维修处理单量',
                                type:'line',
                                data:datas['maintain']['de'],//[1, 3, 2, 5, 9, 2, 10],
                                markPoint: {
                                    data: [
                                        {type: 'max', name: '最大值'},
                                        {type: 'min', name: '最小值'}
                                    ]
                                },
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            }
                        ]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);
                </script>
            </div>
          </div>
        </div>
    </div>

</div>
